/* GUI CONVERTED from rprsrp04.p (converter v1.75) Tue Aug 22 11:49:25 2000 */
/* rprsrp04.p - PRODUCT LINE RESOURCE LOAD DETAIL REPORT                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/* web convert rprsrp04.p (converter v1.00) Fri Oct 10 13:57:19 1997 */
/* web tag in rprsrp04.p (converter v1.00) Mon Oct 06 14:17:45 1997 */
/*F0PN*/ /*K1DD*/ /*                                                    */
/*V8:ConvertMode=FullGUIReport                                 */
/* REVISION: 1.0     LAST MODIFIED: 05/13/86    BY: emb         */
/* REVISION: 4.0     LAST MODIFIED: 02/24/88    BY: wug *A175*      */
/* REVISION: 4.0     LAST MODIFIED: 06/20/89    BY: emb *A748*      */
/* REVISION: 4.0     LAST MODIFIED: 02/22/90    BY: wug *B583*      */
/* REVISION: 7.0     LAST MODIFIED: 10/11/91    BY: emb *F024*      */
/* REVISION: 7.3     LAST MODIFIED: 10/23/92    BY: ram *G231*      */
/* REVISION: 7.3     LAST MODIFIED: 10/18/94    BY: jzs *GN61*      */
/* REVISION: 8.6     LAST MODIFIED: 12/11/97    BY: bvm *K1DD*      */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/22/00   BY: *N0K5* Arul Victoria   */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*GN61*/ {mfdtitle.i "b+ "}

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *
 * &SCOPED-DEFINE rprsrp04_p_1 "Workdays     "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_2 "Total Load   "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_3 "Over/Under   "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_4 "Capacity     "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_5 "P/L"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_6 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp04_p_8 "Cumulative   "
 * /* MaxLen: Comment: */
 *
 *N0K5* ------------------- END   DELETE ----------------------- */

/* ********** Begin Translatable Strings Definitions ********* */
&SCOPED-DEFINE rprsrp04_p_7 "Per Column"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp04_p_9 "Day/Week/Month"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

     define variable start like pq_start.
     define variable start1 like pq_start.
     define variable rsc like pq_rsc.
     define variable rsc1 like pq_rsc.
     define variable site like pq_site.
     define variable site1 like pq_site.

     define variable interval as integer extent 14.
     define variable sdate like ro_start extent 14.
     define variable load as decimal extent 14 format ">>>>,>>9".
     define variable cap as decimal extent 14 format ">>>>,>>9".
     define variable ovund as decimal extent 14 format "->>>,>>9".
     define variable cum as decimal extent 14 format "->>>,>>9".
     define variable workdays as integer extent 14 format ">>>>,>>9".
     define variable periods as integer extent 14 format ">>>>,>>9".
     define variable det_load as decimal extent 14 format ">>>>,>>9".
     define variable holiday as integer.
     define variable i as integer.
     define variable j as integer.
     define variable qty like pq_qty.
     define variable wostart as integer.
     define variable nonwdays as decimal.
     define variable elapsedays as integer.
     define variable wdays as integer.
     define variable overlap as integer.
     define variable wointerval as integer.
     define variable offset like pq_lt_off.
     define variable ltoff like pq_lt_off.
     define variable ltoffperiod as integer.
     define variable lead as integer.
     define variable dwm as character format "!(1)" label {&rprsrp04_p_9}.
     define variable idays as integer format ">>>>>9" label {&rprsrp04_p_7}.
     define variable monthend as integer.
     define variable num_intervals as integer initial 13.
     define variable period as integer.
     define variable prod_start as date.
     define variable prod_end as date.
     define variable rscde like rs_rsc.
     define variable more like mfc_logical.

/*GN61 moved 1st column from 15 to 25 in frame a. (jzs) */
     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
site           colon 25
        site1          label {t001.i} colon 49
        rsc            colon 25
        rsc1           label {t001.i} colon 49 skip (1)
        start          colon 25 skip
        dwm            colon 25 skip
        idays          colon 25 skip
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     site = global_site.
     site1 = global_site.

/*K1DD*/ {wbrp01.i}

         
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

/*GN61      do with frame a: */
           if start = ? then start = date(month (today),1,year (today)).
           if dwm = "" then dwm = "M".
           if idays = 0 or idays = ? then idays = 1.
           if rsc1 = hi_char then rsc1 = "".
           if site1 = hi_char then site1 = "".

           display site site1 rsc rsc1 start dwm idays
/*GN61*/    with frame a.

/*K1DD*/       if c-application-mode <> 'web' then
               
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K1DD*/ {wbrp06.i &command = set &fields = "  site site1 rsc rsc1 start
               idays " &frm = "a"}

/*K1DD*/ if (c-application-mode <> 'web') or
/*K1DD*/ (c-application-mode = 'web' and
/*K1DD*/ (c-web-request begins 'data')) then do:

           if day(start) <> 1 then do:
          start = date(month (start),1,year (start)).
          display start with frame a.
           end.

           bcdparm = "".
           {mfquoter.i site   }
           {mfquoter.i site1  }
           {mfquoter.i rsc    }
           {mfquoter.i rsc1   }
           {mfquoter.i start  }
           {mfquoter.i idays  }

           if rsc1 = "" then rsc1 = hi_char.
           if site1 = "" then site1 = hi_char.

/*K1DD*/ end.

              
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:


 /* SELECT PRINT DESTINATION/BATCH */
           {mfphead.i}

/*GN61      end. */

        for each rs_mstr no-lock where rs_rsc >= rsc and rs_rsc <= rsc1
        and rs_site >= site and rs_site <= site1:

           display rs_rsc rs_desc no-label rs_um space(6) rs_site
           with
/*N0K5*/   frame c
              width 132 side-labels STREAM-IO /*GUI*/ .

/*N0K5* ------------------- BEGIN ADD ----------------------- */
           /* SET EXTERNAL LABELS */
           setFrameLabels(frame c:handle).
/*N0K5* ------------------- END   ADD ----------------------- */

           /* COMPUTE START DATES */
           sdate[1] = min(today,start).
           {mfcsdate.i}

           display space(14)
/*N0K5* {&rprsrp04_p_6}  */
/*N0K5*/         getTermLabel("PAST",8)
           sdate[2 for 12] skip
           space(14) sdate[2] - 1 sdate[3] - 1 sdate[4] - 1 sdate[5] - 1
             sdate[6] - 1 sdate[7] - 1 sdate[8] - 1 sdate[9] - 1
            sdate[10] - 1 sdate[11] - 1 sdate[12] - 1 sdate[13] - 1
            sdate[14] - 1 skip
           "              -------- -------- -------- -------- --------"
           "--------"
           "-------- -------- -------- -------- -------- -------- --------"
           skip
           with frame b no-labels width 132 STREAM-IO /*GUI*/ .

           /* INITIALIZE VARIABLES */
           cap = 0.
           workdays = 0.
           periods = 0.
           load = 0.
           ovund = 0.
           cum = 0.

           /* CALCULATE WORKING DAYS IN EACH INTERVAL */
           {mfcwdays.i rs_site}

           display
/*N0K5* {&rprsrp04_p_1} */
/*N0K5*/         getTermLabel("WORKDAYS",13) format "x(13)"
                 workdays[1 for 13]
           with frame b no-labels width 132 STREAM-IO /*GUI*/ .

           /* CALCULATE CAPACITY IN EACH INTERVAL */
           rscde = rs_rsc.
/*G231         {mfccap.i} */
/*G231*/       {mfccap.i rs_site}

           display
/*N0K5* {&rprsrp04_p_4} */
/*N0K5*/         getTermLabel("CAPACITY",13) format "x(13)"
              cap[1 for 13]
           with frame b no-labels width 132 STREAM-IO /*GUI*/ .

           /* CALCULATE  LOAD IN EACH PERIOD  */
           for each pq_mstr no-lock where pq_rsc = rscde
           and pq_site = rs_site
           by pq_prod_line:

          for each pp_plan no-lock where pp_prod_line = pq_prod_line
          and pp_site = pq_site
          and (pp_year >= year (pq_start) or pq_start = ?)
          and (pp_year <= year (pq_end) or pq_end =?)
          by pp_year:

             /* CALCULATE LOAD FOR A PRODUCT LINE PRODUCTION PLAN */
             /* Initialize det_load array */
             det_load = 0.

             period_loop:
             do period = 1 to 12:

            /* CALCULATE PRODUCT LINE RESOURCE LOAD */
            {mfpqld.i}

             end.

             /* DISPLAY FORECAST LOAD DETAIL */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *           display
 *             {&rprsrp04_p_5}
 *              pq_prod_line pp_year det_load[1 for 13]
 *           with no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
             display
                getTermLabel("PRODUCT_LINE",4) format "x(4)"
                pq_prod_line pp_year  skip
                space(14) det_load[1 for 13]
             with no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */

          end.
           end.

           /* DISPLAY LOAD OVER/UNDER AND CUMULATIVE */
           display
/*N0K5* {&rprsrp04_p_2}     */
/*N0K5*/         getTermLabel("TOTAL_LOAD",13) format "x(13)"
              load[1 for 13]
           with frame d no-labels width 132 STREAM-IO /*GUI*/ .

           do i = 1 to num_intervals + 1:
          ovund[i] = cap[i] - load[i].
          ovund[i] = integer(ovund[i]).
          cum[i] = ovund[i].
          if i > 1 then cum[i] = cum[i] + cum[i - 1].
           end.

           display
/*N0K5* {&rprsrp04_p_3} */
/*N0K5*/         getTermLabel("OVER/UNDER",13) format "x(13)"
              ovund[1 for 13]
           with frame d no-labels width 132 STREAM-IO /*GUI*/ .

           display
/*N0K5* {&rprsrp04_p_8} */
/*N0K5*/         getTermLabel("CUMULATIVE",13) format "x(13)"
              cum[1 for 13]
           with frame d no-labels width 132 STREAM-IO /*GUI*/ .

           
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/


        end.
        
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

     end.

/*K1DD*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" site site1 rsc rsc1 start idays  "} /*Drive the Report*/
